package com.etc.controller;

import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.util.VerifyCode;

/**
 * 获取图片验证码
 */
@WebServlet("/VerifyCodeController")
public class VerifyCodeController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private VerifyCode vc = new VerifyCode(); 

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BufferedImage image = vc.getImage();
		request.getSession().setAttribute("verifyCode", vc.getText());
		VerifyCode.output(image, response.getOutputStream());
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
